package com.netty.rpc.encode;

import com.netty.rpc.req.Request;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

public class Decode extends ByteToMessageDecoder {

    private Class cla;

    public Decode(Class clazz){
        this.cla = clazz;
    }

    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        Object object = CodeC.decode(cla,byteBuf);
        list.add(object);
    }
}
